<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <link rel="icon" href="<%= BASE_URL %>favicon.ico">
    <title><%= htmlWebpackPlugin.options.title %></title>
  </head>
  <body>
    <noscript>
      <strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
    </noscript>
    <div id="app"></div>
    <script>
      window.addEventListener(
          "error",
          function(e) {
            var jsLoadedErrorReload = window.sessionStorage.getItem(
                "jsLoadedErrorReload"   // 跳转的标识，存入sessionStorage。用于不可控情况下，防止一直满足条件，触发死循环性的跳转页面
            );
            // const fileReg = /\/js\/((chunk-vendors)|(app))\.[a-zA-Z0-9]+/;
            const fileReg = /.js$/;
            const filename = e.filename || e.target.src || "";
            if (jsLoadedErrorReload !== "true" && filename.match(fileReg)) {
              window.sessionStorage.setItem("jsLoadedErrorReload", true);  // 满足条件则，存入标识
              let url = window.location.href;
              const timeStr = `errortimestr=${Date.now()}`;
              url = /\?/.test(url) ? url + "&" + timeStr : url + "?" + timeStr;
              window.location.replace(url); // 跳转时添加了时间戳
            }
          }, true);
    </script>
    <!-- built files will be auto injected -->
  </body>
</html>
